Page({
  data: {
    temp: "",
  },
  onLoad: function (options) {},

  chooseImage: function () {
    wx.chooseMedia({
      count: 1,
      mediaType: ["image", "video"],
      sourceType: ["album", "camera"],
      sizeType: ["original", "compressed"],
      camera: "back",
      success: (res) => {
        console.log(res);
        this.setData({
          temp: res.tempFiles[0].tempFilePath,
        });
      },
    });
  },

  upload() {
    wx.uploadFile({
      filePath: this.data.temp,
      name: "files",
      url: "http://nodeseq.srliforever.ltd/upload/files",
      formData: {
        nickname: "zhangsan",
      },
      success: (res) => {
        const data = JSON.parse(res.data);
        console.log(data.data[0].url);
      },
    });
  },
});
